import pygame
import air_sprites


class AirGame(object):
    def __init__(self):
        print("游戏初始化")
        # 创建游戏窗口
        self.screen = pygame.display.set_mode(air_sprites.SCREEN_RECT.size)
        # 创建游戏时钟
        self.clock = pygame.time.Clock()
        # 创建精灵
        self.__creat_sprites()

    def __creat_sprites(self):
        pass

    def start_game(self):
        print("游戏开始")
        while True:
            self.clock.tick(air_sprites.FPS)
            self.__event_handler()
            self.__check_collide()
            self.__update_sprites()
            pygame.display.update()

    def __event_handler(self):
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                AirGame.__game_over()   # 静态方法调用需用到类名
        pass

    def __check_collide(self):
        pass

    def __update_sprites(self):
        pass

    @staticmethod   # 定义静态方法
    def __game_over():
        print("游戏结束")
        pygame.quit()
        exit()


if __name__ == '__main__':
    game = AirGame()
    game.start_game()
